﻿#include<iostream>
#include<map>

void printMap(std::map<int , int> &m)
{
	for (std::map<int, int>::iterator it = m.begin(); it != m.end(); ++it)
	{
		std::cout << "key = " << it->first << "   value = " << (*it).second << '\n';
	}
	std::cout << '\n';

}
void test01()
{
	std::map<int, int> m1;
	m1.insert(std::pair<int, int>(1, 10));
	m1.insert(std::pair<int, int>(3, 30));
	m1.insert(std::pair<int, int>(2, 20));
	m1.insert(std::pair<int, int>(5, 50));
	m1.insert(std::pair<int, int>(4, 40));
	m1.insert(std::pair<int, int>(6, 60));
	m1.insert(std::pair<int, int>(8, 80));
	m1.insert(std::pair<int, int>(7, 70));

	//10 20 30 40 50 60 70 80 
	printMap(m1);

	//10 30 40 50 60 70 80
	m1.erase(++m1.begin());
	printMap(m1);

	//10 30 70 80
	m1.erase(++++m1.begin() , ----m1.end());
	printMap(m1);

	//10 30 70
	m1.erase(8);
	printMap(m1);

	m1.clear();
	printMap(m1);

}

int main()
{
	test01();


	return 0;
}
